package com.cn.dao.impl;

import java.util.List;

import org.hibernate.Query;

import com.cn.dao.ServicetypeDAO;

public class ServicetypeDAOImpl extends BaseHibernateDAOImpl implements ServicetypeDAO{

	
	public List listAllType() {
		try {
		String queryString = "from Servicetype as stname ";
		getSession().beginTransaction();
		Query queryObject = getSession().createQuery(queryString);
		List list=queryObject.list();
		getSession().getTransaction().commit();
		return list;
		} catch (RuntimeException re) {
			throw re;
		}
	}
	/**
	 * 根据id查找Servicetype
	 * @param id
	 * @return Servicetype对象
	 */
	public Object findById(int id){
		try {
			String queryString = "from Servicetype as st where id ="+id;
			getSession().beginTransaction();
			Query queryObject = getSession().createQuery(queryString);
			List list = queryObject.list();
			getSession().getTransaction().commit();
			if (list.size() == 0) {
				return null;
			}
			return list.get(0);
		} catch (RuntimeException re) {
			throw re;
		}
	}
}
